package cn.wuqingna.legendgem.api.attribute.imp

import cn.wuqingna.legendgem.api.attribute.AbsAttributeSource
import cn.wuqingna.legendgem.api.attribute.AttributeData
import cn.wuqingna.legendgem.gem.GemManager
import org.bukkit.Bukkit
import org.bukkit.entity.Player
import taboolib.platform.util.isNotAir
import java.util.UUID

class OffHandSource(
    val uuid: UUID
): AbsAttributeSource() {
    override fun getAttribute(): AttributeData? {
        val player = Bukkit.getPlayer(uuid) ?: return null
        if (!player.isOnline) { return  null }
        if (player.inventory.itemInOffHand.isNotAir()){
            return GemSource(uuid, GemManager.getItemGems(player.inventory.itemInOffHand, player)).getAttribute()
        }
        return null
    }
}